package Util;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.*;

public class JKeyboardPaneNumerico extends JPanel{
	
	JTextField txt;
	String teclas[]={"1","2","3","4","5","6","7","8","9","0",".","<"};
	ArrayList<JButton> botones=new ArrayList<>();
	JPanel pletras,pespacio;
	
	public JKeyboardPaneNumerico(JTextField t){
		
		txt=t;
		pletras=new JPanel();
//                pletras.setSize(400, 40);
		setLayout(new BorderLayout());
		pletras.setLayout(new GridLayout(4,10,0,0));
		this.setSize(200, 200);
		ActionListener accion=new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
				JButton b=(JButton)e.getSource();
                                b.setPreferredSize(new Dimension(40, 40));
				if(!b.getText().equalsIgnoreCase(" ")){
					txt.setText(""+txt.getText()+b.getText());
				}else{
					txt.setText(txt.getText()+" ");
				}
			}
			
		};
		
		for(int i=0;i<12;i++){
//			if(teclas[i].equalsIgnoreCase("Z")){
//				JLabel l=new JLabel();
//				pletras.add(l);
//			}
			JButton b=new JButton(teclas[i]);
//                        b.setSize(45, 45);
			b.addActionListener(accion);
			pletras.add(b);
			botones.add(b);
		}
		
		pespacio=new JPanel(new GridLayout(10,4));
//                pespacio.setSize(400, 40);
//		JButton bespacio=new JButton(" ");
//		bespacio.addActionListener(accion);
		//pespacio.setSize(400, 400);
                pespacio.add(new JLabel());
		//pespacio.add(bespacio);
		//pespacio.add(new JLabel());
		add(pletras);
		add(pespacio,BorderLayout.SOUTH);
		
	}

}
